package wql.aaa.controller;

import com.aaa.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import wql.aaa.service.ZoneBusinessService;
import wql.aaa.vo.BusinessFromData;
import wql.aaa.vo.SearchFormsData;

/**
 * @author wql
 * @version 1.0
 * @date 2023/2/27 20:39
 */
@RestController
@RequestMapping("/home/zoneBusiness")
public class ZoneBusinessController {

    @Autowired
    private ZoneBusinessService zoneBusinessService;

    @PostMapping("/managementZone/{currentPage}/{pageSize}")
    public Result  query(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody SearchFormsData searchFormsData){
        System.out.println("searchFormsData = " + searchFormsData);
        return zoneBusinessService.queryAll(currentPage,pageSize,searchFormsData);
    }

    @GetMapping("/changeStatus/{id}/{isDisable}")
    public Result updateDisable(@PathVariable String id,@PathVariable Integer isDisable){
        return zoneBusinessService.updateIsDisabled(id,isDisable);
    }

    @GetMapping("/deleteZoneBusiness/{id}")
    public Result delete(@PathVariable String id){
        return zoneBusinessService.deleteById(id);
    }

    @GetMapping("/changeSort/{id}/{sort}")
    public Result changeSort(@PathVariable String id ,@PathVariable Integer sort){
        return zoneBusinessService.changeSort(id,sort);
    }

    @PostMapping("/manageUnstockedStores/{currentPage}/{pageSize}")
    public  Result manageUnstockedStores(@PathVariable Integer currentPage, @PathVariable Integer pageSize,@RequestBody BusinessFromData businessFromData){
        System.out.println("businessFromData = " + businessFromData);
        return  zoneBusinessService.addBusiness(currentPage,pageSize,businessFromData);
    }

    @GetMapping("/addBusinessDetail/{id}/{zoneId}")
    public Result  addBusinessDetail(@PathVariable String id ,@PathVariable String zoneId){
        return  zoneBusinessService.addBusinessDetail(id ,zoneId);
    }

    @PostMapping("/changePutAway/{id}")
    public Result changePutAway(@PathVariable String id){
        return  zoneBusinessService.changePutAway(id);
    }

}
